package com.wechat.it.isales.member.controller;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.wechat.it.isales.member.service.IMemberService;
import com.wechat.it.isales.member.vo.MemberVO;

@Controller
@RequestMapping("/member")
public class MemberController {

	@RequestMapping(value = "getInfo", method = { RequestMethod.POST, RequestMethod.GET })
	public @ResponseBody
	Map<String, List<MemberVO>> getInfo(List<MemberVO> list) {
		Map<String, List<MemberVO>> map = new HashMap<String, List<MemberVO>>();

		for (MemberVO memberBean : list) {
			map.put(memberBean.getName(), memberService.findByName(memberBean.getName()));
		}
		return map;
	}

	@RequestMapping(value = "getInfo2", method = { RequestMethod.POST, RequestMethod.GET })
	public @ResponseBody
	Map<String, List<MemberVO>> getInfo() {
		Map<String, List<MemberVO>> map = new HashMap<String, List<MemberVO>>();
		List<MemberVO> list = memberService.findAll();
		for (MemberVO memberBean : list) {
			map.put(memberBean.getName(), list);
		}
		return map;
	}

	@RequestMapping(value = "getcount", method = { RequestMethod.POST, RequestMethod.GET })
	public String getcount() {
		return "getcount";
	}

	@Autowired
	private IMemberService memberService;
}
